<template>
  <div class="course-content">
    <van-swipe class="my-swipe" :autoplay="3000" indicator-color="white">
      <van-swipe-item v-for="item in ActiveAdList" :key="item.id">
        <img :src="item.img">
      </van-swipe-item>
    </van-swipe>
    <!-- 课程列表 -->
    <course-content-list :get-course="getCourse" ></course-content-list>
  </div>
</template>

<script>
import { Swipe, SwipeItem } from 'vant'
import { getAllAds, getQueryCourses } from '@/services/course'
import CourseContentList from '@/components/CourseContentList.vue'
export default {
  components: { CourseContentList, VanSwipe: Swipe, VanSwipeItem: SwipeItem },
  name: 'CourseContent',
  data () {
    return {
      adList: []
    }
  },
  created () {
    this.loadAds()
  },
  methods: {
    getCourse (option) {
      return getQueryCourses(option)
    },
    async loadAds () {
      const { data } = await getAllAds({ spaceKeys: '999', status: 1 })
      if (data.state === 1) {
        this.adList = data.content[0].adDTOList
      }
    }
  },
  computed: {
    ActiveAdList () {
      return this.adList.filter(item => item.status === 1)
    }
  }
}
</script>

<style scoped>
.my-swipe {
  width: 100%;
}
.my-swipe .van-swipe-item {
 display: flex;
 justify-content: center;
 overflow: hidden;
}
.van-swipe img {
  height: 170px;
}
.course-content-list {
  top: 220px;
  bottom: 50px;
}
</style>
